<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title></title>
		<script type="text/javascript" src="../0js/vue.js"></script>
	</head>
	<body>
		<div id="root">
			<h1>性别: {{student.sex}}</h1>
			<button @click="addSex">添加一个性别属性，默认值是男</button>

		</div>
	</body>

	<script type="text/javascript">
		Vue.config.productionTip = false

		const vm = new Vue({
			el:'#root',
			data:{
				school:{
					name:'vue',
					address:'北京',
				},
				student:{
					name:'tom',
					friends:[
						{name:'jerry',age:35},
						{name:'tony',age:36}
					]
				}
			},
			methods: {
				addSex(){
					// vm.$set(); 动态添加对象属性
					this.$set(this.student,'sex','男')
				}
			}
		})
	</script>
</html>